package com.atxiaodei.kabudashejimoshi.单例模式.反射破坏单例;

import com.atxiaodei.kabudashejimoshi.单例模式.lazy.LazyStaticInnerClassSingleton;

import java.lang.reflect.Constructor;

public class ReflectTest {

    public static void main(String[] args) {
        try {
            Class<?> clazz = LazyStaticInnerClassSingleton.class;
            Constructor c = clazz.getDeclaredConstructor(null);

            // 私有方法 强制访问
            c.setAccessible(true);

            Object instance1 = c.newInstance();

            Object instance2 = c.newInstance();


            System.out.println(instance1);

            System.out.println(instance2);

            System.out.println(instance1 == instance2);


//            Enum

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
